const { response } = require('express');
var express = require('express');
var router = express.Router();

/* GET users listing. */
router.get('/testajax', function(req, res, next) {
  console.log("后台接收到资源")
  //获得前端传入的参数
  let {callback,id} = req.query;
  console.log("callback====>",callback)
  //查询数据。。。。
    res.send(callback+"({code:0,msg:'two',id:'"+id+"'"+"})")
    //res.json({code:0,msg:'two',id:`${id}`})
});

//测试代理服务器的
router.get('/getstudent', function(req, res, next) {
  console.log("后台接收到资源")
  //获得前端传入的参数
   res.json({
    code:1,
    msg:"查询成功",
    data:{
      id:1,
      name:"学生1",
      age:19,
      class:{
          id:1,
          name:"班级1"
      }
    }
   })
});

router.get('/getmsg', function(req, res, next) {
  console.log("后台接收到资源")
  //获得前端传入的参数
   res.json({msg:"第二个方法"})
});


module.exports = router;


   



